{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "9c6e9d1d143c419bb68000bf582c03cf",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Plot(antialias=3, axes=['x', 'y', 'z'], axes_helper=1.0, background_color=16777215, camera=[2.235852213410751,…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "\"\"\"Compute the (signed) distance from one mesh to another.\"\"\"\n",
    "\n",
    "from vedo import *\n",
    "embedWindow('k3d') # or k3d\n",
    "\n",
    "s1 = Sphere().flat() # flat shading\n",
    "s2 = Cube(pos=(1,0,0), c='white', alpha=0.2)\n",
    "\n",
    "# add scalars to the sphere that correspond to their distance from the cube\n",
    "s1.distanceToMesh(s2, signed=True, negate=False)\n",
    "\n",
    "#s1.printInfo()\n",
    "#print(s1.getPointArray(\"Distance\"))\n",
    "\n",
    "show(s1, s2, viewup='z')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
